-
Notifications
You must be signed in to change notification settings - Fork 52
feat: Add Valkey and RDMA support for KV-cache indexing #139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add Valkey and RDMA support for KV-cache indexing #139
Conversation
- Add Valkey backend support as Redis-compatible alternative - Implement RDMA configuration for future high-performance scenarios - Add comprehensive test suite for Valkey functionality - Update documentation with Valkey configuration options - Provide example implementation and usage guide - Maintain full backward compatibility with existing Redis backend Fixes llm-d#134
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Valkey backend support as a Redis-compatible alternative for KV-cache indexing, including RDMA configuration for high-performance scenarios. The implementation maintains full backward compatibility with the existing Redis backend while providing enhanced performance options.
- Add Valkey backend with RDMA support configuration
- Implement comprehensive test suite for Valkey functionality
- Provide example implementation and configuration documentation
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/kvcache/kvblock/valkey_test.go | Comprehensive test suite for Valkey backend functionality |
| pkg/kvcache/kvblock/redis.go | Extended Redis implementation to support Valkey backend with RDMA |
| pkg/kvcache/kvblock/index.go | Added Valkey configuration support to index factory |
| examples/valkey_example/main.go | Complete example demonstrating Valkey usage |
| examples/valkey_example/README.md | Documentation for Valkey example usage |
| examples/valkey_configuration.md | Configuration guide for Valkey backend |
| docs/configuration.md | Updated configuration documentation with Valkey options |
| docs/architecture.md | Added Valkey backend description to architecture |
| README.md | Updated main README with Valkey example reference |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
pkg/kvcache/kvblock/valkey_test.go
Outdated
| shouldSucceed: true, | ||
| }, | ||
| { | ||
| name: "valkey with RDMA enabled", |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after comma should be removed.
| name: "valkey with RDMA enabled", | |
| name: "valkey with RDMA enabled", |
pkg/kvcache/kvblock/valkey_test.go
Outdated
| name: "valkeys:// SSL URL scheme", | ||
| config: &RedisIndexConfig{ | ||
| Address: "valkeys://" + server.Addr(), | ||
| BackendType: "valkey", |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after comma should be removed.
| BackendType: "valkey", | |
| BackendType: "valkey", |
pkg/kvcache/kvblock/valkey_test.go
Outdated
| expectError: false, | ||
| }, | ||
| { | ||
| name: "valkey:// scheme", |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after comma should be removed.
| name: "valkey:// scheme", | |
| name: "valkey:// scheme", |
pkg/kvcache/kvblock/redis.go
Outdated
| // DefaultValkeyIndexConfig returns a default configuration for Valkey. | ||
| func DefaultValkeyIndexConfig() *RedisIndexConfig { | ||
| return &RedisIndexConfig{ | ||
| Address: "valkey://127.0.0.1:6379", |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after comma should be removed.
| Address: "valkey://127.0.0.1:6379", | |
| Address: "valkey://127.0.0.1:6379", |
pkg/kvcache/kvblock/redis.go
Outdated
| // Convert valkey:// to redis:// for protocol compatibility | ||
| config.Address = strings.Replace(config.Address, "valkey://", "redis://", 1) | ||
| } else if strings.HasPrefix(config.Address, "valkeys://") { | ||
| // Convert valkeys:// to rediss:// for SSL protocol compatibility |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after compatibility should be removed.
| // Convert valkeys:// to rediss:// for SSL protocol compatibility | |
| // Convert valkeys:// to rediss:// for SSL protocol compatibility |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
examples/valkey_example/main.go
Outdated
|
|
||
| const ( | ||
| envValkeyAddr = "VALKEY_ADDR" | ||
| envValkeyEnableRDMA = "VALKEY_ENABLE_RDMA" |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after string should be removed.
| envValkeyEnableRDMA = "VALKEY_ENABLE_RDMA" | |
| envValkeyEnableRDMA = "VALKEY_ENABLE_RDMA" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
examples/valkey_example/main.go
Outdated
| // Test prompts to demonstrate caching behavior | ||
| prompts := []string{ | ||
| "Hello, how are you today?", | ||
| "What is the weather like?", |
Copilot
AI
Oct 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra trailing space after comma should be removed.
| "What is the weather like?", | |
| "What is the weather like?", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rishi-jat thank you for the contribution - looks great overall! I added a few minor comments.
examples/valkey_example/main.go
Outdated
| func demonstrateValkeyOperations(ctx context.Context, indexer *kvcache.Indexer) error { | ||
| logger := klog.FromContext(ctx).WithName("valkey-demo") | ||
|
|
||
| // Test prompts to demonstrate caching behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be preferable to reuse the testdata package's content as done in the other examples.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
examples/valkey_example/main.go
Outdated
| logger.Info("Adding cache entries manually to demonstrate Valkey backend") | ||
|
|
||
| // Simulate cache entries for the first prompt | ||
| firstPromptKeys := []kvblock.Key{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expanding on the above point - this example would fail as these hashes will not be regenerated by the indexer. It is best to use the content of the testdata package, including the pre-calculated hashes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
| } | ||
|
|
||
| // Future: Add RDMA configuration for Valkey when supported | ||
| if config.BackendType == "valkey" && config.EnableRDMA { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be clear - only the configuration is not supported, but RDMA will still work if configured in the valkey instance?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed.
|
@vMaroon Thanks for the review! I’ll address all the suggestions as soon as possible. |
- Use testdata package in Valkey example as requested by @vMaroon - Replace hardcoded hashes with pre-calculated testdata.PromptHashes - Fix example to demonstrate proper cache behavior with real data - Add clarification about RDMA support in Go client vs server - Clean up code formatting and remove trailing spaces - Add implementation documentation Addresses feedback from PR llm-d#139 Signed-off-by: Rishi Jat <[email protected]>
|
@vMaroon I’ve implemented all the suggested changes. Please let me know if I missed anything or if further adjustments are needed. Thanks! |
Thanks Rishi - can you confirm that the examples run as expected? Then we'll be good to go after fixing the linting issue.
Sure! Thank you for pointing this out. |
- Fix errcheck issues by properly handling server.Close() in defer functions - Replace if-else chain with switch statement for better readability - Remove duplicate code branches in URL scheme handling - Add log message for RDMA configuration to avoid empty branch warning - Simplify createValkeyConfig() to remove unused error return - All tests continue to pass after linting fixes Fixes linting errors in PR llm-d#139 Signed-off-by: Rishi Jat <[email protected]>
|
@vMaroon I fixed the CI issue. |
|
please review when you get a chance. |
- Fix errcheck warnings by properly checking type assertion results - Fix gofumpt and goimports formatting issues in redis.go - Ensure all code follows project linting standards
|
Thanks @rishi-jat! /lgtm |


Summary
Fixes #134